<?php

class Story_Form_Chapter extends Engine_Form
{
	protected $_item;	
	public function getItem(){
		return $this->_item;
	}
	
	public function setItem(Core_Model_Item_Abstract $item)	{
		$this->_item = $item;
		return $this;
	}
	
	public function init()
	{		
		$this->addElement('Text', 'title', array(
				'label' => 'Title',
				'allowEmpty' => false,
				'required' => true,
				'filters' => array(
						'StripTags',
						new Engine_Filter_Censor(),
						new Engine_Filter_StringLength(array('max' => '127')),
				)));

		$this->addElement('TinyMce', 'body', array(
				'label' => 'Body',
				'required' => true,
				'allowEmpty' => false,
				'validators' => array(
					array('stringLength', false, array(255)),
				),
				'filters' => array(
						new Engine_Filter_Censor(),
				),
				'editorOptions' => array(
						//'upload_url' => $upload_url,
						'remove_script_host' => '',
						'convert_urls' => '',
						'relative_urls' => '',
						'mode' => 'exact',
						'elements' => 'body',
						'width' => 500,
						'height' => 420,
						'media_strict' => false,
						'extended_valid_elements' => '*[*],**,object[width|height|classid|codebase|id|name],param[name|value],embed[src|type|width|height|flashvars|wmode|id|name],iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder|id|name|class],video[src|type|width|height|flashvars|wmode|class|poster|preload|id|name],source[src]',
						'plugins' => "emotions, table, fullscreen, preview, paste, style, layer, xhtmlxtras",
						'theme_advanced_buttons1' => "cut,copy,paste,pastetext,pasteword,|,undo,redo,|,link,unlink,anchor,charmap,image,media,|,justifyleft,justifycenter,justifyright,justifyfull,|,hr,removeformat,code,preview",
						'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,|,bullist,numlist,|,outdent,indent,|,tablecontrols",
						'theme_advanced_buttons3' => "formatselect,fontselect,fontsizeselect,|,forecolor,backcolor,|,styleprops,attribs,|,blockquote,sub,sup",
				)
		));

		$this->addElement('Hidden', 'story_id', array(
				'validators' => array(
						'Int',
				)
		));
		
		$title = "Add Chapter";
		
		if($this->_item->category_id == Story_Model_Category::SCRIPT_PLAY){	
			$title = "Add Scene";
		};

		// Buttons
		$this->addElement('Button', 'submit', array(
				'label' => $title,
				'type' => 'submit',
				'ignore' => true,
				'decorators' => array('ViewHelper')
		));

		$this->addElement('Cancel', 'cancel', array(
				'label' => 'cancel',
				'link' => true,
				'onclick' => 'parent.Smoothbox.close();',
				'prependText' => ' or ',
				'decorators' => array(
						'ViewHelper'
				)
		));

		$this->addDisplayGroup(array('submit', 'cancel'), 'buttons');
		$button_group = $this->getDisplayGroup('buttons');
		$button_group->addDecorator('DivDivDivWrapper');
	}

}